const day = require("dayjs");
/**
 * 应该传入 “YY-MM-DD” 来确定日期，再获取那一天的一周
 * @param {string} x 
 */

const get7Day = (x = "2021-01-11") => {
    let day0 = day(x);
    let arr = [];
    let wek = day0.$W;
    let last = day().add(0,"day") - day0;
    last = Math.ceil(last / (1000*60*60*24)) - 1;
    wek = wek === 0 ? -6 : -(wek - 1);
    for (let i = 0; i < 7; i++) {
        arr.push(day().add(wek+i-last, "day"));
    }
    return arr;
};
module.exports = {
    get7Day
}